package datastructure.leetcode.linked;

import common.ListNode;

/**
 * @author cyt
 * @create 2020-11-28 10:56
 */
public class T141 {
    public static void main(String[] args) {

    }

    /**
     * 判断环形 链表
     *
     * @param head
     * @return
     */
    public boolean isCyCle(ListNode head) {
        if (head == null || head.next == null) {
            return false;
        }
        ListNode slow = head;
        ListNode fast = head.next.next;
        while (fast != null && fast.next != null) {
            if (slow == fast) {
                return true;
            }
            slow = slow.next;
            fast = fast.next.next;
        }
        return false;
    }
}
